import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt'
import { ConfigService } from '@nestjs/config'
import { CreateJwtCommandHandler } from './commands/create-jwt.command.handler';
import { AuthJwtStrategy } from './providers/auth-jwt.strategy';
const commdHnadler = [CreateJwtCommandHandler]
@Module({
  imports: [JwtModule.registerAsync({
    inject: [ConfigService],
    useFactory: (configService: ConfigService) => ({
      privateKey: configService.get('JWT.privateKey'),
      signOptions: {
        // 时效
        // expiresIn:'60s',
        // 签名算法
        algorithm: "RS256"
      }
    }),
  })],
  providers: [...commdHnadler, AuthJwtStrategy],
  exports: [JwtModule, ...commdHnadler]
})
export class AuthJwtModule { }
